﻿using System.Windows.Forms;
using Tao.OpenGl;

namespace GameLoop
{
    public partial class Form1 : Form
    {
        private FastLoop _fastLoop;
        private bool _fullScreen = false;

        public Form1()
        {
            _fastLoop = new FastLoop(GameLoop);
            InitializeComponent();
            simpleOpenGlControl1.InitializeContexts();

            if(_fullScreen)
            {
                FormBorderStyle = FormBorderStyle.None;
                WindowState = FormWindowState.Maximized;
            }
        }

        private void GameLoop(double elapsedTime)
        {
            Gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
            Gl.glPointSize(5.0f);
            Gl.glRotated(10*elapsedTime,0,1,0);
            Gl.glBegin(Gl.GL_TRIANGLE_STRIP);
            {
                Gl.glColor3d(1.0,0.0,0.0);
                Gl.glVertex3d(-0.5,0,0);
                Gl.glColor3d(0.0,1.0,0.0);
                Gl.glVertex3d(0.5, 0, 0);
                Gl.glColor3d(0.0,0.0,1.0);
                Gl.glVertex3d(0, 0.5, 0);
            }
            Gl.glEnd();
            Gl.glFinish();
            simpleOpenGlControl1.Refresh();
        }
    }
}
